cmake_minimum_required(VERSION 3.5)

project(mcdpgenerator VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

set(PROJECT_SOURCES
        ui/mainwindow.ui
        ui/newdp.ui
        res.qrc
        sources/Datapack.cpp 
        sources/main.cpp 
        sources/newdp.cpp 
        sources/PackMcmeta.cpp 
        sources/Namespace.cpp 
        sources/mainwindow.cpp 
        sources/dpfile_types/AdvancementFile.cpp 
        sources/dpfile_types/DimensionFile.cpp
        sources/dpfile_types/NoiseFile.cpp
        sources/dpfile_types/LootTableFile.cpp 
        sources/dpfile_types/ItemModifierFile.cpp 
        sources/dpfile_types/ConfiguredFeatureFile.cpp 
        sources/dpfile_types/DamageTypeFile.cpp 
        sources/dpfile_types/EnchantmentProviderFile.cpp 
        sources/dpfile_types/PlacedFeatureFile.cpp 
        sources/dpfile_types/PaintingVariantFile.cpp 
        sources/dpfile_types/PredicateFile.cpp 
        sources/dpfile_types/DensityFunctionFile.cpp 
        sources/dpfile_types/StructureFile.cpp 
        sources/dpfile_types/ChatTypeFile.cpp 
        sources/dpfile_types/EnchantmentFile.cpp 
        sources/dpfile_types/RecipeFile.cpp 
        sources/dpfile_types/ConfiguredCarverFile.cpp 
        sources/dpfile_types/DimensionTypeFile.cpp 
        sources/dpfile_types/FunctionFile.cpp 
        sources/dpfile_types/BannerPatternFile.cpp 
        sources/dpfile_types/WorldPresetFile.cpp 
        sources/dpfile_types/TemplatePoolFile.cpp 
        sources/dpfile_types/StructureSetFile.cpp 
        sources/dpfile_types/MultiNoiseBiomeSourceParameterListFile.cpp 
        sources/dpfile_types/FlatLevelGeneratorPresetFile.cpp 
        sources/dpfile_types/BiomeFile.cpp 
        sources/dpfile_types/ProcessorListFile.cpp 
        sources/dpfile_types/NoiseSettingsFile.cpp 
        headers/dpfile_types/AdvancementFile.h 
        headers/dpfile_types/DimensionTypeFile.h
        headers/dpfile_types/NoiseFile.h
        headers/dpfile_types/PredicateFile.h 
        headers/mainwindow.h 
        headers/dpfile_types/TemplatePoolFile.h 
        headers/dpfile_types/ItemModifierFile.h 
        headers/newdp.h 
        headers/dpfile_types/RecipeFile.h 
        headers/Datapack.h 
        headers/dpfile_types/WorldPresetFile.h 
        headers/dpfile_types/DatapackFile.h 
        headers/dpfile_types/DamageTypeFile.h 
        headers/dpfile_types/MultiNoiseBiomeSourceParameterListFile.h 
        headers/dpfile_types/FlatLevelGeneratorPresetFile.h 
        headers/dpfile_types/LootTableFile.h 
        headers/dpfile_types/EnchantmentProviderFile.h 
        headers/dpfile_types/DimensionFile.h 
        headers/dpfile_types/ConfiguredCarverFile.h 
        headers/dpfile_types/DensityFunctionFile.h 
        headers/dpfile_types/BannerPatternFile.h 
        headers/dpfile_types/FunctionFile.h 
        headers/Namespace.h 
        headers/PackMcmeta.h 
        headers/dpfile_types/ChatTypeFile.h 
        headers/dpfile_types/EnchantmentFile.h 
        headers/dpfile_types/NoiseSettingsFile.h 
        headers/dpfile_types/PlacedFeatureFile.h 
        headers/dpfile_types/StructureFile.h 
        headers/dpfile_types/ConfiguredFeatureFile.h 
        headers/dpfile_types/ProcessorListFile.h 
        headers/dpfile_types/StructureSetFile.h 
        headers/dpfile_types/BiomeFile.h 
        headers/dpfile_types/PaintingVariantFile.h
        includes/JsonLite.h
        ui/ui_mainwindow.h
        ui/ui_newdp.h
        headers/dpfile_types_includes.h)



if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    qt_add_executable(mcdpgenerator
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
            )
    # Define target properties for Android with Qt 6 as:
    #    set_property(TARGET mcdpgenerator APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
    #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
    # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else ()
    if (ANDROID)
        add_library(mcdpgenerator SHARED
                ${PROJECT_SOURCES}
                )
        # Define properties for Android with Qt 5 after find_package() calls as:
        #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
    else ()
        add_executable(mcdpgenerator
                ${PROJECT_SOURCES}
                )
    endif ()
endif ()

target_link_libraries(mcdpgenerator PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

set_target_properties(mcdpgenerator PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
        )

install(TARGETS mcdpgenerator
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
        )

if (QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(mcdpgenerator)
endif ()
